package com.pi.config;




import com.pi.core.exchange.vo.CommonNameRegistryService;
import com.pi.pro.xcmg.am.common.XcmgAmConstants;
import com.pi.pro.xcmg.am.was.edi.wcs.common.WcsWasXcmgExchangeConstants;
import com.pi.pro.xcmg.am.was.edi.wcs.service.TasklistServiceProxy;
import com.pi.wms.fac.conn.HttpAccessUrl;
import com.pi.wms.fac.conn.HttpclientProxy;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;



/**
 *
 */
@Configuration
public class WcsWmsClientExchangeConfig {



/**==================================================================================================================**/
//  WH101/
/**==================================================================================================================**/

    @Value("${wcs.api.was.wh101.code}")
    private String wcsWh101ServiceCode;

    @Value("${wcs.api.was.wh101.warehousecode}")
    private String wcsWh101Warehousecode;

    /**
    @Value("${wcs.api.was.wh101.token}")
    private String wcsWh101Token;
    **/


    /**
     * TASK
     */
    @Value("${wcs.api.was.wh101.task.client.code}")
    private String wcsTaskWh101ClientCode;

    @Value("${wcs.api.was.wh101.task.func.execute.url}")
    private String wcsTaskExeuteWh101PostAccessUrl;


/**==================================================================================================================**/
//  all
/**==================================================================================================================**/

    @Bean
    public CommonNameRegistryService wcsNameRegistryService(){
        CommonNameRegistryService nameRegistryService = new CommonNameRegistryService(WcsWasXcmgExchangeConstants.WCS_ENDPOINT_NAMESPACE);
        nameRegistryService.clientnMapping(XcmgAmConstants.clients);
        nameRegistryService.orgnizationMapping(XcmgAmConstants.organizations);
        return nameRegistryService;
    }





/**==================================================================================================================**/
//  WH101
/**==================================================================================================================**/

    /**********************************************/
    //** Task
    /**********************************************/
    @Bean
    public HttpAccessUrl wcsTaskExecuteWh101PostAccessUrl(){
        HttpAccessUrl accessUrl=new HttpAccessUrl();
        accessUrl.setUrl(this.wcsTaskExeuteWh101PostAccessUrl);
        return accessUrl;
    }

    @Bean
    public HttpclientProxy wcsTaskWh101Client(){
        HttpclientProxy client=new HttpclientProxy(this.wcsTaskWh101ClientCode);
        return client;
    }

    @Bean
    public TasklistServiceProxy wcsTaskWh101ServiceProxy(){
        TasklistServiceProxy proxy=new TasklistServiceProxy();
        proxy.setCategory(this.wcsWh101ServiceCode);
        proxy.setCode(this.wcsWh101ServiceCode+this.wcsTaskWh101ClientCode);
        proxy.setWcsTaskClient(this.wcsTaskWh101Client());
        //proxy.setToken(this.wcsWh101Token);
        proxy.setWcsTaskExecutePostAccessUrl(this.wcsTaskExecuteWh101PostAccessUrl());
        this.wcsNameRegistryService().register(proxy);
        return proxy;
    }



}
